import axios from "axios";
import qs from 'qs';
import {
    isPlainObject
} from '../assets/util.js';
import {
    Notify
} from 'vant';

const http = axios.create({
    baseURL: 'http://backend-api-01.newbee.ltd/api/v1/',
    timeout: 60000,
    transformRequest: data => {
        if (isPlainObject(data)) return qs.stringify(data);
        return data;
    },
    headers: {
        // 设置后端需要的传参类型
        'token': '148730cff9671bb7693a23fc859c1c9d',
    },
});
http.interceptors.request.use(config => {
    return config;
});
http.interceptors.response.use(response => {
    return response.data;
}, reason => {
    Notify({
        type: 'danger',
        message: '小主,当前网络繁忙,请稍后再试!'
    });
    return Promise.reject(reason);
});
export default http;